package com.crowdfunding.service.impl;

import com.crowdfunding.entity.CrowdFunding;
import com.crowdfunding.entity.CrowdFundingDetail;
import com.crowdfunding.entity.CrowdfundingImage;
import com.crowdfunding.service.CrowdFundingDetailService;
import com.crowdfunding.service.ICrowdFundingService;
import com.crowdfunding.service.ICrowdfundingImageService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CrowdFundingDetailServiceImpl implements CrowdFundingDetailService {

    @Autowired
    ICrowdFundingService crowdFundingService;
    @Autowired
    ICrowdfundingImageService imageService;

    @Override
    public CrowdFundingDetail getDetail(String cfId) {
        CrowdFunding crowdFunding=crowdFundingService.getOneCrowFunding(cfId);
       CrowdFundingDetail crowdFundingDetail= new CrowdFundingDetail();
       //父类对象给子类对象赋值
        BeanUtils.copyProperties(crowdFunding,crowdFundingDetail);
        //查询出该众筹活动的图片列表并赋值
        List<CrowdfundingImage> imageList=imageService.getImageListByCfId(cfId);
       crowdFundingDetail.setImageList(imageList);
        return crowdFundingDetail;
    }
}
